{{ template "layout/header" .}}

{{/*是否登录:{{.islogin}}*/}}
<script>
    if ({{.islogin }}) {
        location.href = "/"
    }
</script>
<main id="body">
    <div class="container">
        <div class="row">
            <div class="col-lg-6 mx-auto">
                <div class="card">
                    <div class="card-header">
                        用户登录
                    </div>
                    <div class="card-body ajax_modal_body">
                        <form action="/api/v1/login" method="post" id="form">
                            <div class="form-group input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="icon icon-user icon-fw"></i></span>
                                </div>
                                <input type="text" class="form-control" placeholder="Email / 用户名" id="email"
                                    name="email">
                                <div class="invalid-feedback"></div>
                            </div>
                            <div class="form-group input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="icon icon-lock icon-fw"></i></span>
                                </div>
                                <input type="password" class="form-control" placeholder="密码" id="password"
                                    name="password">
                                <div class="invalid-feedback"></div>
                            </div>
                            <div class="form-group">
                                <button type="button" class="btn btn-primary btn-block" id="submit">登录</button>
                            </div>
                            {{/*<style>
                                .third-login .third-login-btns a {
                                    cursor: pointer;
                                    display: inline-block;
                                    vertical-align: middle;
                                    margin: 0 13px;
                                    background-image: url(//www.lgstatic.com/www/static/common/widgets/passport/static/images/third-sprite_d07ffce.png);
                                    background-repeat: no-repeat;
                                }

                                .third-login .wechat {
                                    width: 27px;
                                    height: 27px;
                                    background-position: -102px -206px;
                                }
                            </style>
                            <div class="third-login">
                                <span>第三方账号登录</span>
                                <div class="third-login-btns">
                                    <a class="weibo" rel="nofollow" href="https://passport.lagou.com/oauth20/auth_sinaWeiboProvider.html" title="使用新浪微博帐号登录"></a>
                                    <a class="wechat" rel="nofollow" href="https://passport.lagou.com/oauth20/auth_weixinProvider.html" title="使用微信帐号登录"></a>
                                    <a class="qq" rel="nofollow" href="https://passport.lagou.com/oauth20/auth_qqProvider.html" title="使用腾讯QQ帐号登录"></a>
                                    <a class="baidu" rel="nofollow" href="https://passport.lagou.com/oauth20/auth_baiduProvider.html" title="使用百度帐号登录"></a>
                                </div>
                            </div>*/}}
                            <div class="media">
                                <div>
                                </div>
                                <div class="media-body text-right">
                                    <a href="/password/forget.html" class="text-muted"><small>忘记密码</small></a>
                                    <a href="/register.html" class="text-muted"><small>用户注册</small></a>
                                </div>
                            </div>

                            {{/*引入微信登录*/}}
                            {{ template "layout/thirdlogin" .}}

                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>

<script>
    var jform = $('#form');
    var jsubmit = $('#submit');
    var jemail = $('#email');
    var jpassword = $('#password');
    var referer = '/';
    jsubmit.on('click', function () {
        jform.reset();
        var postdata = jform.serializeObject();
        $.ajax({
            method: "post",
            url: jform.attr('action'),
            data: postdata,
            acync: false,
            success: function (res) {
                if (res.code == 200) {
                    $.alert("登录成功")
                    setTimeout(function () {
                        $.location("/")
                    }, 2000)
                } else {
                    $.alert("用户名或密码错误")
                    jsubmit.button('reset');
                }
            }
        })

        return false;
    });
</script>

{{ template "layout/footer" }}
